import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import AutoImport from 'unplugin-auto-import/vite';
import svgLoader from 'vite-svg-loader';
// https://vitejs.dev/config/

export default defineConfig(({ command,mode})=>{
  const env = loadEnv(mode, process.cwd(), "");

  console.log('111',env.VITE_HOST_URL);
  return {
    server:{
      port:8888,
      proxy:{
          "^/api":{
          target:env.VITE_HOST_URL,
          changeOrigin:true, // 是否跨域
          // rewrite:(path) => path.replace(/^\/api/,""),
    },
    },
    
    },
    plugins: [
      vue(),svgLoader(),
      AutoImport({
          imports:["vue","vue-router","pinia"],
      }),
      Components({
       
        resolvers: [
          AntDesignVueResolver({
            importStyle: false, // css in js
          }),
        ],
      }),
    ],
    resolve:{
      extensions: [".js",".vue"],
    }
    
  }
});


